package servlet;

import com.ncist.dao.MessagesDao;
import com.ncist.dao.yaoguaiDao;
import com.ncist.pojo.Messages;
import com.ncist.pojo.yaoguai;
import com.ncist.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@WebServlet("/chatform")
public class chatservlet extends HttpServlet {
    SqlSession sqlSession;

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        sqlSession = MybatisUtils.getSqlSession();
        String name = request.getParameter("name");
        String sex = request.getParameter("sex");
        String wechat = request.getParameter("wechat");
        String age = request.getParameter("age");

        yaoguaiDao mapper = sqlSession.getMapper(yaoguaiDao.class);

        if (sex.equals("女")) {
            System.out.println(1);
            List<yaoguai> x=mapper.insertmm(name,wechat);
            response.sendRedirect("join.jsp");

        }
        else {
            System.out.println(2);
            response.sendRedirect("join.jsp");

        }
        sqlSession.close();
    }
    }